package cn.lcsjsxy.yxz.day.Abnormal;

//自定义异常
public class Custom {

    public static void main(String[] args) {

        String account = "1";
        String password = "1";
        try {
            zhanghao(account, password);
        }catch (AccountException accountException){
            System.out.println("账号不对");
        }catch (PasswordException passwordException){
            System.out.println("账号不确");
        }catch (LoginException loginException){
            System.out.println("其他错误");
        }

    }

    public static void zhanghao(String account, String password){

        if (!"admin".equals(account)){
            throw new AccountException("账号不正确");
        }
        if (!"admin".equals(password)){
            throw new PasswordException("账号不正确");
        }
        System.out.println("登录成功");

    }
}

class AccountException extends LoginException{
    public AccountException(String message){
        super(message);
    }
}
class PasswordException extends LoginException{
    public PasswordException(String message){
        super(message);
    }
}

class LoginException extends RuntimeException{
    public LoginException(String message){
        super(message);
    }
}